import request from '@/utils/request'

// 员工api
export const getEmployeeListAPI = (params) => {
  return request({
    url: '/sys/user',
    params
  })
}

// 删除员工
export const delEmployeeAPI = (id) => {
  return request({
    url: '/sys/user/' + id,
    method: 'DELETE'
  })
}

// 用户下载，导入员工excel文件
export const exportEmployeeAPI = () => {
  return request({
    url: '/sys/user/export',
    // 因为axios返回数据格式默认是二进制，要转换数据格式为二进制
    responseType: 'blob'
  })
}

// 下载模板，获取导入员工模板
export const getTemplateAPI = () => {
  return request({
    url: '/sys/user/import/template',
    responseType: 'blob'
  })
}

// 用户上传文件到后台
export const uploadFileAPI = (data) => {
  return request({
    url: '/sys/user/import',
    method: 'post',
    data
  })
}

// 添加员工
export const addEmployeeAPI = (data) => {
  return request({
    url: '/sys/user',
    method: 'post',
    data
  })
}

// 获取员工详情
export const getEmployeeDetailAPI = (id) => {
  return request('/sys/user/' + id)
}

// 编辑员工
export const editEmployeeAPI = (data) => {
  return request({
    url: '/sys/user/' + data.id,
    method: 'put',
    data
  })
}

// 获取已启用角色列表，用于渲染勾选
export const getEnableListAPI = () => {
  return request('/sys/role/list/enabled')
}
